﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;


namespace FAP.DataAccess.BLL
{
    public class website
    {
        public int id { get; set; }
        public string link { get; set; }
        public int trangthai { get; set; }
        public string tag { get; set; }
        public bool isdeleted { get; set; }
        //public List<danhmuc> danhmucs { get { return danhmuc.danhmucSelectRowByForeignKey_websiteid(id); } }
        //public List<chitietnghiepvu> chitietnghiepvus { get { return chitietnghiepvu.chitietnghiepvuSelectRowByForeignKey_websiteid(id); } }
        //public List<taikhoan> taikhoans { get { return taikhoan.taikhoanSelectRowByForeignKey_websiteid(id); } }

        #region websiteSelectAll
        public static List<website> websiteSelectAll()
        {
            IDataReader dr = FAP.DataAccess.DAL.websiteSelectAll();
            List<website> websiteList = new List<website>();
            while (dr.Read())
            {
                website mywebsite = new website
                {
                    id = !dr.IsDBNull(dr.GetOrdinal("id")) ? (int)dr["id"] : 0,
                    link = !dr.IsDBNull(dr.GetOrdinal("link")) ? (string)dr["link"] : null,
                    trangthai = !dr.IsDBNull(dr.GetOrdinal("trangthai")) ? (int)dr["trangthai"] : 0,
                    tag = !dr.IsDBNull(dr.GetOrdinal("tag")) ? (string)dr["tag"] : null,
                    isdeleted = !dr.IsDBNull(dr.GetOrdinal("isdeleted")) ? (bool)dr["isdeleted"] : false
                };
                websiteList.Add(mywebsite);
            }
            dr.Close();
            dr.Dispose();
            return websiteList;
        }
        #endregion

        #region websiteSelectRow
        public static website websiteSelectRow(int id)
        {
            IDataReader dr = FAP.DataAccess.DAL.websiteSelectRow(id);
            website website = null;

            if (dr.Read())
            {
                website = new website
                {
                    id = !dr.IsDBNull(dr.GetOrdinal("id")) ? (int)dr["id"] : 0,
                    link = !dr.IsDBNull(dr.GetOrdinal("link")) ? (string)dr["link"] : null,
                    trangthai = !dr.IsDBNull(dr.GetOrdinal("trangthai")) ? (int)dr["trangthai"] : 0,
                    tag = !dr.IsDBNull(dr.GetOrdinal("tag")) ? (string)dr["tag"] : null,
                    isdeleted = !dr.IsDBNull(dr.GetOrdinal("isdeleted")) ? (bool)dr["isdeleted"] : false,

                };
            }
            dr.Close();
            dr.Dispose();
            return website;
        }
        #endregion

        #region websiteInsertRow
        public static void websiteInsertRow(string link, int trangthai, string tag, bool isdeleted)
        {
            FAP.DataAccess.DAL.websiteInsertRow(link, trangthai, tag, isdeleted);
        }
        #endregion

        #region websiteUpdateRow
        public static void websiteUpdateRow(int id, string link, int trangthai, string tag, bool isdeleted)
        {
            FAP.DataAccess.DAL.websiteUpdateRow(id, link, trangthai, tag, isdeleted);
        }
        #endregion

        #region websiteDeleteRow
        public static void websiteDeleteRow(int id)
        {
            FAP.DataAccess.DAL.websiteDeleteRow(id);
        }
        #endregion
    }
}